﻿<title>我的天联云-个人资料</title>


<link href="/SiteUI/MyBiz/Index.css" rel="stylesheet" />
<script src="/LiberUI/Scripts/jquery.js"></script>
<script src="/LiberUI/Scripts/LiberUI.Base.js"></script>

<script>
    SoBiz.Template("_level2");
</script>
<body>
    <script type="text/html" section="ContentNavi" src="/MyBiz/_pvNaviLv2.html">

    </script>

    <script type="text/html" section="PageBody">
        <div class="col-lg-10 col-lg-offset-1">
            <div class="row" id="acntSumUp">
                <div class="col-lg-2">
                    <img id="userheadimg" src="/UserFile/DefaultUserLogo.png" />
                </div>
                <div class="col-lg-5" style="padding-top:3rem">
                    <span id="username"></span>&nbsp;&nbsp;<span class="People no-certificated"></span><br />
                    <a class="LinkTo" id="headImgLink" href="javascript:void(0);">修改头像</a><span>&nbsp;|&nbsp;</span><a class="LinkTo" href="/MyBiz/AlterPwd" id="btnResetPwd">修改密码</a>
                </div>
            </div>
            <div class="row infoRow">
                <div class="col-lg-3 df-title">
                    手机绑定：
                </div>
                <div id="showPhone" class="col-lg-6 df-value">

                </div>
                <div class="col-lg-3 df-action">
                    <a class="LinkTo" href="/MyBiz/AlterPhone">更换手机</a>
                </div>
            </div>
            <div class="row infoRow">
                <div class="col-lg-3 df-title">
                    实名认证：
                </div>
                <div id="realNameStatus" class="col-lg-6 df-value">
                    &nbsp;
                </div>
                <div class="col-lg-3 df-action">
                    <a id="realNameStatusLink" class="LinkTo" href="/MyBiz/AlterCertify.html">申请认证</a>
                </div>
            </div>
            <div class="row infoRow">
                <div class="col-lg-3 df-title">
                    微信账号绑定：
                </div>
                <div id="wechatState" class="col-lg-6 df-value">
                    未绑定|已绑定【微信昵称】
                </div>
                <div class="col-lg-3 df-action">
                    <a id="wechatBind" class="LinkTo" href="/MyBiz/BindWechat">绑定</a>
                </div>
            </div>
        </div>
        <div class="col-lg-10 col-lg-offset-1 personalData" id="myCompany">
            <div id="myCompanyCard">
                <div class="row">
                    <div class="col-lg-12 personalData_details">我的企业</div>
                </div>
            </div>
            <h6 style="margin-top:2rem"><a class="LinkTo" href="~/SetCompany.html?Company">加入/创建企业</a></h6>
            提示：只能选择一个企业设为企业名片，设为企业名片了，个人主页显示的个人企业名称为设置的企业名称。
        </div>
    </script>
    <script>
    Index = {
        html: "",
        onUserReady: function () {
            $(".People").attr("objid",User.idstr);
            //头像
            $("#userheadimg").attr("src", User.headimg);
            //手机号
            $("#showPhone").vl(User.acnt);
            //姓名
            $("#username").vl((User.realname) ? User.realname : User.username);
            //实名认证
            switch (User.certifystatus) {
                case "Pending": //审核中
                    $("#realNameStatus").vl("正在认证审核中");
                    $("#realNameStatusLink").vl("查看详情");
                    break;
                case "Aborted": //审核不通过
                    $("#realNameStatus").vl("您的实名认证未通过审核，请重新申请");
                    break;
                case "Completed":  //审核通过
                    $(".People").removeClass("no-certificated").addClass("certificated");
                    $("#realNameStatus").vl("您的实名认证已通过审核");
                    $("#realNameStatusLink").vl("查看详情");
                    break;
            }
            //公司名片
            Index.companyCard();
            //微信
            Index.wechatCard();
        },
        updateHeadImg: function (ev) {
            switch (ev.Status) {
                case "imageLoaded":
                    $("#userheadimg").attr("src", ev.Item.thumbnail);
                    break;
                case "uploadEnd":
                    $.getJSON("/MyBiz/UpdateHeadimg", { headimg: encodeURI(ev.Item.Result.path) }, function (ev) {
                        if (ev.IsPositive) {
                            success("成功", "头像已修改成功");
                            User.headimg = ev.Item.Result.path;
                            $("#userheadimg").attr("src", User.headimg);
                        }
                        else {
                            $("#userheadimg").attr("src", User.headimg);
                            error("失败", "没能完成修改头像操作，请稍后再试");
                        }
                    });
                    break;
            }
        },
        companyCard: function () {
            if (User.Orgs.length > 0) {
                //TODO:找到所有公司节点
                Index.html += " <div class='row companyCard '>";
                Index.html += "<div class='col-lg-12'>";
                Index.html += "<div class='col-lg-2'>"
                Index.html += " <img style='height:5rem;margin-top:0.5rem' src='" + User.Orgs[0].logourl + "'></div>";
                Index.html += " <div class='col-lg-4 col-lg-offset-1' style='margin-top:0.5rem ;text-align: center;'>";
                Index.html += " <h5>" + User.Orgs[0].realname + "</h5>";
                Index.html += " 岗位：</div>";
                Index.html += "<div class='col-lg-3 col-lg-offset-2' style='line-height:6rem'>";
                if (User.Orgs[0].status == "Active") {
                    Index.html += " <div class='button ' >设为企业名片</div> ";
                }else {

                }
                Index.html += " </div> </div></div> ";
                $("#myCompanyCard").append(Index.html);
                Index.html = "";
            }
        },
        wechatCard: function () {
            if (!User.wxname) {
                //无绑定
                $("#wechatState").vl("未绑定 ! 绑定微信号可实时获取重要业务信息");
                $("#wechatBind").attr("href", "/MyBiz/BindWechat.html").vl("绑定");
            }
            else {
                //有绑定
                $("#wechatState").vl("已绑定微信号：" + User.wxname);
                $("#wechatBind").attr("href", "#").on("click", function () {
                    $.getJSON("/MyBiz/UnbindWechat", null, function () {
                        window.history.go(0);
                    });
                }).vl("解除绑定").show();
            }
        }
    }

    SoBiz.Ready(function () {
        new LiberUI.Uploader("#headImgLink")
                    .option("FileType", "image/*")
                    .option("MaxSize", 8 * 1024 * 1024)
                    .update()
                    .on("change", Index.updateHeadImg);
        SoBiz.Login(Index.onUserReady);
    });
    </script>
</body>

